package base;

import java.util.*;
import java.text.*;

public class Common
{
    public Common()
    {
    }

    public static void main(String[] args)
    {
        Common common = new Common();
    }

    public static String trim(String str)
    {
        if (str != null)
        {
            return str.trim();
        }
        return "";
    }

    public static String getNow()
    {
        Calendar cal = Calendar.getInstance();

        SimpleDateFormat formatter = new SimpleDateFormat(
                "yyyy-MM-dd HH:mm:ss");

        String mDateTime = formatter.format(cal.getTime());

        return (mDateTime);
    }

    public static String formatClientWordsToHtml(String str)
    {
        str = str.replaceAll("\n", "<br/>");
        return str;
    }

    public static String MakeSureNotNull(Object object)
    {
        return object != null ? (String) object : "-999";
    }

    private String convert(String str)
    {
        String tmp;
        StringBuffer sb = new StringBuffer(1000);
        char c;
        int i, j;
        sb.setLength(0);
        for (i = 0; i < str.length(); i++)
        {
            c = str.charAt(i);
            if (c > 255)
            {
                sb.append("\\u");
                j = (c >>> 8);
                tmp = Integer.toHexString(j);
                if (tmp.length() == 1) sb.append("0");
                sb.append(tmp);
                j = (c & 0xff);
                tmp = Integer.toHexString(j);
                if (tmp.length() == 1) sb.append("0");
                sb.append(tmp);
            }
            else
            {
                sb.append(c);
            }

        }
        return (new String(sb));
    }

}

